import org.antlr.runtime.*;
import java.io.BufferedWriter;
import java.io.FileWriter;

public class Compilador {
 	public static void main(String[] args) {
 		try { //args[0] = opcion, args[1] = file
               Javalex lexer = new Javalex(new ANTLRFileStream(args[0]));
               CommonTokenStream tokens = new CommonTokenStream(lexer);
               Javasint parser = new Javasint(tokens);
               //System.out.println("principio");
               parser.program();
               
               //System.out.println("final: " + parser.codigoSAM);
           	   BufferedWriter out = new BufferedWriter(new FileWriter("test/out.sam"));
           	   out.write(parser.codigoSAM.toString());
           	   out.close();
         } catch (Exception e) {
        	   System.out.println("error");
        	   e.printStackTrace();
         }
 	} //main
}

